package qrcode

// 小程序二维码管理

import (
    "fmt"
	"wxsdk/miniapp/core"
	//"github.com/astaxie/beego"
)

const (
	urlWxAqrcode = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=%s"
)

// 获取小程序二维码，直达页面
type WxAqrCodeRequest struct {
	Path      string  `json:"path"`
	Width     int     `json:"width"`
}

func CreateWxAqrCode(accessToken, path string) (body []byte, err error) {
	url := fmt.Sprintf(urlWxAcodeUnlimit, accessToken)
	client := core.GetPostJSONClient()
	var req = new(WxAqrCodeRequest)
	req.Path = path
	req.Width = 430
	body, err = client.Excute("POST", url, req, nil)
	return
}
